﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Intelligent.OTC.Common;
using System.Web;

namespace Intelligent.OTC.Business
{
    public class CacheService : ICacheService
    {
        public T GetOrSet<T>(string cacheKey, Func<T> getItemCallBack) where T : class
        {
            T item = HttpContext.Current.Cache.Get(cacheKey) as T;
            if (item == null)
            {
            //    lock (this)
            //    {
            //        if (item == null)
            //        {
                        item = getItemCallBack();
                        HttpContext.Current.Cache.Insert(cacheKey, item);
            //        }
            //    }
            }
            return item;
        }

    }
}
